<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@page import="java.util.*,model.*,util.*,control.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>resources_upload_chuli.jsp</title>
</head>
<body>
<%
   request.setCharacterEncoding("UTF-8");
   
   ArrayList resources_idlist=(ArrayList)session.getAttribute("resources_idlist");
   ArrayList resources_namelist=(ArrayList)session.getAttribute("resources_namelist");
   ArrayList resources_typelist=(ArrayList)session.getAttribute("resources_typelist");
   Resources resources=new Resources();
   ResourcesControl rc=new ResourcesControl();
   if(resources_idlist.size()==0){
       //System.out.println("未上传文件！");
      %>
      <script language="javascript">
        alert("未选择文件！");
       window.location.href="resources.jsp";
     </script>
      <%
   }else{
       for(int i=0;i<(resources_idlist.size());i++){
           String resources_path=(String)(resources_idlist.get(i));
           String resources_name=(String)(resources_namelist.get(i));
           String resources_type=(String)(resources_typelist.get(i));
           //获取系统时间
           java.util.Date date = new java.util.Date();//获得系统时间.
           String resources_uploadtime = new SimpleDateFormat("yyyy-MM-dd").format(date);//将时间格式转换成符合date要求的格式.
        
           String resources_uploadusername=(session.getAttribute("shetuanName")).toString();//获得username
		   ShetuanControl uc = new ShetuanControl();
		   int resources_uploaduserId=uc.getShetuanId(resources_uploadusername);
           
           System.out.println(resources_name);
           resources.setName(resources_name);
           resources.setType(resources_type);
           resources.setPath(resources_path);
           resources.setUploadtime(resources_uploadtime);
           resources.setUploaduserId(resources_uploaduserId);
           if(rc.insertResources(resources))System.out.println("添加文件信息成功");
           else System.out.println("添加文件信息失败");
       }
       response.sendRedirect("resources.jsp");
   }
%>
</body>
</html>